package game.entity.action;

import edu.monash.fit2099.engine.Action;
import edu.monash.fit2099.engine.Actor;
import edu.monash.fit2099.engine.GameMap;
import edu.monash.fit2099.engine.Item;
import game.CoinPoint;
import game.entity.actor.Brachiosaur;
import game.entity.behavior.HungerBehaviour;
import game.entity.behavior.SleepBehaviour;

public class FeedAction extends Action {

    private Actor target;
    private Item fruit;

    public FeedAction(Actor target, Item fruit) {
        this.target = target;
        this.fruit = fruit;
    }

    @Override
    public String execute(Actor actor, GameMap map) {
        if(fruit.canFeed()){
            if(target instanceof Brachiosaur){
                //如果玩家喂养，每种水果使恐龙的食物水平增加20。
                target.heal(20);
                CoinPoint.addPoints(10,"feed "+target);
            }else{
                target.heal(fruit.getHealPoints());
            }
            actor.removeItemFromInventory(fruit);
            if(target.getBehavior() instanceof SleepBehaviour){
//            清除昏迷状态
                target.setBehaviour(new HungerBehaviour(target));
            }
            return "feed successfully,heal "+ target +" 10 hitPoints";
        }
        return "feed "+ target+" fail";
    }

    @Override
    public String menuDescription(Actor actor) {
        return "feed "+ target +" 1 fruit";
    }
}
